﻿<Window x:Class="Wpf2.Views.FormEditBeforePrintAddOrder"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Nhập kho - Sửa trước khi in"
        Width="Auto" Height="616.418"  WindowStartupLocation="CenterScreen" WindowState="Maximized"
        >
    <StackPanel Orientation="Vertical" Background="#FF3C2AF9" Margin="0,0,0,18">
        <StackPanel Margin="10,10,10,0" Height="50" >
            <StackPanel  Orientation="Horizontal" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
                <Label Height="30" Content="Tên cửa hàng"></Label>
                <TextBox Name="txtStoreName" Text="KHANG HUY" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" Width="84" Height="20" Margin="0,15" ></TextBox>
                <Label Height="30" Content="Địa chỉ" Margin="20,0,0,0"></Label>
                <TextBox Name="txtAddress" Width="200" Height="20" Text="667 CMT8, KP2, Thị Xã Tây Ninh"></TextBox>
                <Label Height="30" Content="Di động" Margin="20,0,0,0"></Label>
                <TextBox Name="txtMobile" Width="81" Height="20" Text="0982777728" Margin="0,15" ></TextBox>
                <Label Height="30" Content="Điện thoại" Margin="20,0,0,0"></Label>
                <TextBox Name="txtPhone" Width="86" Height="20" Text="(066)2220333" Margin="0,15"></TextBox>
                <StackPanel Margin="20,0,20,0" HorizontalAlignment="Right"  Width="120" Height="30" Orientation="Horizontal">
                    <Button x:Name="btnPrint" Click="BtnPrintClick"  Width="90" Background="#16499A">
                        <TextBlock Foreground="#FFFCFCFC"> In</TextBlock>
                    </Button>
                    <StackPanel Width="30" Height="30" Background="#FF0050EF">
                        <Image Source="/Wpf2;component/Images/print.png" />
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </StackPanel>

        <DataGrid Height="436"  x:Name="dtgInventory" ItemsSource="{Binding}" Background="White" AutoGenerateColumns="False" CanUserAddRows="False" Margin="10,10,10,10" AlternatingRowBackground="PaleTurquoise" >
            <DataGrid.RowHeaderTemplate>
                <DataTemplate>
                    <TextBlock  Width="20" Text="{Binding Header, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}, Mode=FindAncestor}}"/>
                </DataTemplate>
            </DataGrid.RowHeaderTemplate>

            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Mã Sản Phẩm" Width="auto">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid VerticalAlignment="Bottom" HorizontalAlignment="Center">
                                <TextBox Height="20" Width="80" Text="{Binding ProductId, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="{x:Null}"/>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Tên Sản Phẩm" Width="150">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid VerticalAlignment="Bottom" HorizontalAlignment="Center">
                                <TextBox Height="20" Width="100" Text="{Binding ProductName, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="{x:Null}"/>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Mô Tả" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid VerticalAlignment="Bottom" HorizontalAlignment="Center">
                                <TextBox Height="20" Width="100" Text="{Binding ProductDescription, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="{x:Null}"/>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <!-- BeginRegion-->
                <!-- DataGird không thể sử dụng elementName => phải dùng Source-->
                <!-- hiện lỗi không sao! cứ bỏ qua-->
                <!-- Xử lý dạng Đá Hoa Cương (9/5/2014)-->
                <DataGridTemplateColumn Header="Dài" Width="80" IsReadOnly="True" CanUserSort="False">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding ProductHeight, UpdateSourceTrigger=LostFocus}" BorderThickness="0"  Background="{x:Null}"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Rộng" Width="80" IsReadOnly="True" CanUserSort="False">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding ProductWidth, UpdateSourceTrigger=LostFocus}"  BorderThickness="0" Background="{x:Null}"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <!-- EndRegion-->
                <DataGridTemplateColumn Header="Số Lượng" Width="50">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding InventoryCount, UpdateSourceTrigger=PropertyChanged}" PreviewTextInput="IsAcceptNumberic" BorderThickness="0" Background="{x:Null}" TextChanged="TextchangedCaculationPayment"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <!-- Chức năng Đá Hoa Cương: thêm ngày (9/5/14)-->
                <DataGridTextColumn Header="M2" Binding="{Binding ProductM2, UpdateSourceTrigger=PropertyChanged}" Width="80" IsReadOnly="True" CanUserSort="False"/>
                <DataGridTemplateColumn Header="Giá" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding CostPrice, UpdateSourceTrigger=PropertyChanged,StringFormat={}\{0:###\,##0\}}" PreviewTextInput="IsAcceptNumberic" BorderThickness="0" Background="{x:Null}" TextChanged="TextchangedCaculationPayment"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Đơn vị" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding UnitName, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="{x:Null}"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Nhóm" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding CatalogName, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="{x:Null}"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Thành Tiền" Width="*">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding TotalInPayment, StringFormat=\{0:###\,##0\} VNĐ, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" KeyDown="ExcuteAddNewRow" Background="{x:Null}"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        <StackPanel Background="#FFF6F6F6" Margin="10,0,10,10">
            <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right" Margin="10">
                <Label Content="Tổng cộng: "/>
                <TextBox Name="txtTotalPayment" Height="25" Width="100"></TextBox>
            </StackPanel>
        </StackPanel>
        

    </StackPanel>
</Window>
